let greenTime=15;
let redTime=10;
let yellowTime=3;
let sec=document.querySelector('.sec');
let is='1';

Red=document.querySelector('.red');
Green=document.querySelector('.green');
Yellow=document.querySelector('.yellow');
let nowLight='red';
let secTime=redTime;
setInterval(function(){
    if (secTime > 0) {
        secTime--;
        //绿灯最后3秒闪烁（未实现）
        // if(secTime<=3&&nowLight==='green'){
        //     setInterval(function(){
        //         if(is==='1'){
        //             Green.style.backgroundColor='green';
        //             is=0;
        //         }else{
        //             Green.style.backgroundColor='black';
        //             is=1;
        //         }
        //     },200)
        // }
        sec.innerText = secTime;

    }else {
        if (nowLight==='red') {
            Red.style.backgroundColor='black';
            Green.style.backgroundColor='green';
            nowLight='green';
            secTime=greenTime;
        } else if(nowLight==='green') {
            Green.style.backgroundColor='black';
            Yellow.style.backgroundColor='Yellow';
            nowLight='yellow';
            secTime=yellowTime;
        } else if(nowLight==='yellow') {
            Yellow.style.backgroundColor='black';
            Red.style.backgroundColor='red';
            nowLight='red';
            secTime=redTime;
        }
        sec.innerText = secTime;
    }
},1000)